package guoanmaker.personal.business.controller;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import guoanmaker.personal.business.service.PersonalUserstatisticsServiceInterface;
import guoanmaker.personal.helper.common.AjaxJson;
import guoanmaker.personal.helper.common.abstractobj.ApiController;
import guoanmaker.personal.helper.common.util.SystemHelper;
import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping(ApiController.USERSTATISTICS_URL)
public class PersonalUserstatisticsController {
	
	@Resource
	private AjaxJson ajaxJson;
	
	@Autowired  
	private  PersonalUserstatisticsServiceInterface personalUserstatisticsServiceInterface;
	
	@ApiOperation(value = "领取优惠券", notes = "领取优惠券")
	@RequestMapping(value = "/saveUserstatistics", method = RequestMethod.POST)
	public AjaxJson saveUserstatistics(String userid,int type,String commdityid,HttpServletRequest request){
		try {
			String ipString=SystemHelper.getIp2(request);
			ajaxJson.setSuccess(true).setStatus(200).setMsg("操作成功").setData(personalUserstatisticsServiceInterface.saveUserstatistics(userid,type,commdityid,ipString));
		} catch (Exception e) {
			e.printStackTrace();
			ajaxJson.setSuccess(false).setStatus(250).setMsg("操作失败").setData("错误");
		}
		return ajaxJson;
	}
	
	

}
